package com.boco.ibssystem.common.result;

import lombok.Data;

/**
 * @author: yichaofan
 * @date: 2019年04月25日 11:03
 * @email: hjljy@outlook.com
 * @version: v1.0
 * @description:
 */
@Data
public class AjaxResult {

    private int code;
    private String msg;
    private Object data;

    private static final String FAILEDMSG = "操作失败";
    private static final String SUCCESSMSG = "操作成功";



    public AjaxResult() {
        this.code=200;
        this.msg=SUCCESSMSG;
    }
    public AjaxResult(Object data) {
        setSuccessData(data);
    }

    public AjaxResult(String msg,Object data) {
        setMsg(msg);
        setSuccessData(data);
    }
    public AjaxResult(int code, String msg){
        this.code=code;
        this.msg=msg;
    };
    public void setSuccessData(Object data){
        setData(data);
        code=200;
        msg= SUCCESSMSG;
    }
    public void setSuccessData(String meg,Object data){
        this.data=data;
       setSuccess(msg);
    }
    public void setSuccess(String msg){
        this.code=200;
        this.msg=msg;
    }

    public void setFailed(){
        setFailedMsg(FAILEDMSG);
    }
    public void setFailedMsg(String msg){
        this.code=500;
        this.msg=msg;
    }

}
